package com.lzwk.app.ods.mdb;

import com.lzwk.common.test.TestConstant;
import org.apache.flink.table.api.TableResult;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @title: MdbCDCTables
 * @Author Yeaser
 * @Date: 2022/3/1 15:52
 * @Version 1.0
 * Description: TODO
 */
public class MdbCDCTables {
    public  static void payInvoice(StreamTableEnvironment tenv){

        tenv.executeSql("create table pay_invoice(" +
                " `id` INT, " +
                " `account_id` INT," +
                " `object_option_id` INT," +
                " `paid` INT," +
                " `refund_status` STRING," +
                " `fee` INT," +
                " `source` STRING," +
                " `product` STRING," +
                " `ip` STRING," +
                " `transaction_id` STRING," +
                " `create_time` TIMESTAMP(0)," +
                " `pay_time` TIMESTAMP(0)," +
                " `object_id` INT," +
                " `seller_id` INT," +
                " `comment` STRING," +
                " `refund_reason` STRING," +
                " `pay_type` STRING," +
                " `reconciliation_time` STRING," +
                " `remark` STRING, " +
                " watermark for create_time as create_time - interval '10' second, " +
                "  PRIMARY KEY (`id`) NOT ENFORCED" +
                " )with(" +
                "   'connector'='mysql-cdc', " +
                "   'hostname'='" + TestConstant.TESTHOST + "', " +
                "   'port'='" + TestConstant.TESTPORT + "', " +
                "   'username'='" + TestConstant.TESTUSERNAME + "', " +
                "   'password'='" + TestConstant.TESTPASSWORD + "', " +
                "   'database-name'='" + TestConstant.TESTMDBDB + "', " +
                "   'table-name'='" + TestConstant.TESTMDBCDCPAYINVOICE + "', " +
                "   'server-time-zone'='Asia/Shanghai', " +
                "   'debezium.snapshot.locking.mode' = 'none' " +
                ")");

        
    }

    public  static void mdbAccountAccount(StreamTableEnvironment tenv){

        tenv.executeSql("create table mdb_account_account(" +
                " id int, " +
                " create_time timestamp , " +
                " openid string , " +
                " active_ip string , " +
                " active_time timestamp, " +
                " nickname string, " +
                " headimgurl string, " +
                " sex string, " +
                " country string, " +
                " province string, " +
                " city string, " +
                " telephone string , " +
                " status string , " +
                " subscribed int, " +
                " introduction string, " +
                " role string, " +
                " unionid string , " +
                " is_robot tinyint, " +
                " address string, " +
                " is_vip tinyint, " +
                " mobile_openid string , " +
                " name string, " +
                " pc_openid string ," +
                " device_token string , " +
                " wechat string , " +
                " wxa_openid string , " +
                " register_source string, " +
                " webo_uid string, " +
                " watermark for create_time as create_time - interval '10' second, " +
                "  PRIMARY KEY (`id`) NOT ENFORCED" +
                " )with(" +
                "   'connector'='mysql-cdc', " +
                "   'hostname'='" + TestConstant.TESTHOST + "', " +
                "   'port'='" + TestConstant.TESTPORT + "', " +
                "   'username'='" + TestConstant.TESTUSERNAME + "', " +
                "   'password'='" + TestConstant.TESTPASSWORD + "', " +
                "   'database-name'='" + TestConstant.TESTMDBDB + "', " +
                "   'table-name'='" + TestConstant.TESTMDBCDCACCOUNTACCOUNT + "', " +
                "   'server-time-zone'='Asia/Shanghai', " +
                "   'debezium.snapshot.locking.mode' = 'none' " +
                ")");

    }


}
